package com.controller;

import com.entity.FriendVerifyMessage;
import com.github.pagehelper.PageInfo;
import com.service.FriendVerifyMessageService;
import com.vo.ResponseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 好友验证控制器
 *
 * @author lbb
 * @version 1.0
 * @date 2020.3.22
 */

@RestController
@RequestMapping("/api")
public class FriendVerifyMessageController {
	@Autowired
	private FriendVerifyMessageService friendVerifyMessageService;
	
	/**
	 * 添加好友验证信息
	 *
	 * @param friendVerifyMessage 验证信息
	 * @return
	 */
	@PostMapping("/friendVerifyMessage/add")
	public ResponseVO addFriendVerifyMessage(@RequestBody FriendVerifyMessage friendVerifyMessage) {
		return new ResponseVO("200", null, friendVerifyMessageService.addFriendVerifyMessage(friendVerifyMessage));
	}
	
	/**
	 * 通过查询接收者ID获取到全部验证信息
	 *
	 * @param toUserId 接收者ID
	 * @return
	 */
	@GetMapping("/friendVerifyMessage/getToUserId")
	public ResponseVO getByToUserIdAllFriendVerifyMessage(Integer pageNum,Integer pageSize,Integer toUserId) {
		PageInfo pageInfo = new PageInfo(friendVerifyMessageService.getByToUserIdAllFriendVerifyMessage(pageNum,pageSize,toUserId));
		return new ResponseVO("200", null, pageInfo);
	}
	
	/**
	 * 是否同意
	 * 同意就添加好友信息，否则无需添加
	 *
	 * @param friendVerifyMessage 好友验证状态
	 * @return
	 */
	@PostMapping("/friendVerifyMessage/editStatus")
	public ResponseVO editStatus(@RequestBody FriendVerifyMessage friendVerifyMessage) {
		return new ResponseVO("200", null, friendVerifyMessageService.editStatus(friendVerifyMessage));
	}
}
